﻿/*
 * RegExpress
 * 
 * Copyright (c) 2010, Daniel McGaughran
 * 
 * Licensed under the Apache Licence, Version 2.0 (the "Licence");
 * you may not use this file except in compliance with the Licence.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 * 
 */

using System;
using System.Text.RegularExpressions;
using RegExpressModel.Entities;


namespace RegExpressViewModel
{
	public class SingleMatchCaseViewModel : ViewModelBase
	{
		private SingleMatchCase _model;



		internal SingleMatchCaseViewModel()
		{
			_model = new SingleMatchCase();
		}


		internal SingleMatchCaseViewModel(SingleMatchCase model)
		{
			_model = model;
		}



		public string Input
		{
			get { return _model.Input; }
			set
			{
				_model.Input = value;
				OnPropertyChanged("Input", "ResultStatus", "IsMatch", "HasResult", "MatchResult");
			}
		}


		public MatchResultType ResultStatus
		{
			get { return _model.ResultStatus; }
		}


		public bool IsMatch
		{
			get { return _model.ResultStatus == MatchResultType.Matches; }
		}

		public bool HasResult
		{
			get { return _model.ResultStatus != MatchResultType.Unknown; }
		}


		public Match MatchResult
		{
			get { return _model.MatchResult; }
		}


		public MultiMatchViewModel Parent { get; internal set; }


		public int Index
		{
			get { return _model.Index; }
		}


		public void Refresh()
		{
			OnPropertyChanged("ResultStatus", "IsMatch", "HasResult", "MatchResult");
		}

	}
}
